/**
 * Created by chenxiaozhong on 2016年1月5日16:51:26.
 */
define(["app",
    "controllers/showtimes/EditShareController"
], function (app) {

    var deps = ["$modal","$window","$state"];

    function editShare($modal,$window,$state) {
        return {
            scope : {
            	type : "@",
            	onSelect : "&onSelect"
            },
            link: function ($scope, elem) {
                elem.on("click", function () {
                    var modalInstance = $modal.open({
                        templateUrl: 'views/showtimes/EditShare.html',
                        controller: "EditShareController",
                        backdrop : "static",
                        keyboard: false,
                        resolve : {
                            type : function() {
                                return $scope.type;
                            }
                        },
                        windowClass : "share-view-modal"
                    });

                    modalInstance.result.then(function(data) {
                    	/*$scope.shareVo = [];
                    	if(data!=null){
                    		$scope.shareVo.push(data);
                    		if($scope.onSelect) {
                                $scope.onSelect({$choseShare:$scope.shareVo});
                            }
                    	}*/
                    	$scope.$emit("sharebroadcast"); //事件广播，刷新列表
                    });
                });
                
            }
        };
        
    }

    editShare.$inject = deps;
    return app.lazy.directive("fcEditShare", editShare);
});